Skip to content

TST: CoW with df.isetitem() #50692

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 12, 2023
Merged

Conversation

lithomas1
Copy link
Member

@lithomas1 lithomas1 commented Jan 12, 2023

xref #49473

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Tests added and passed if fixing a bug or adding a new feature
  • All code checks passed.
  • Added type annotations to new arguments/methods/functions.
  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

@lithomas1 lithomas1 changed the title Test cow isetitem TST: CoW with df.isetitem() Jan 12, 2023
assert not np.shares_memory(df["a"].values, df2["a"].values)

df2.loc[0, "a"] = 0
tm.assert_series_equal(df["a"], df_orig["a"]) # Original is unchanged
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use get_array? A regular getitem sets up references which is what we want to avoid here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry wrong line, in the np.shares_memory and any reason why we don't compare the whole object?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use get_array? A regular getitem sets up references which is what we want to avoid here

Changed. Originally, I had put this test in test_setitem.py does the shares_memory checks like this.
Should we change that file over in the future?

Sorry wrong line, in the np.shares_memory and any reason why we don't compare the whole object?

Updated, I had this left over from testing, sorry.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries.

Hm I would not change any existing tests as of right now (still early in CoW adaption). In general this is fine if CoW is not activated, but when explicitly testing CoW we should avoid setting up references to avoid side effects

@phofl phofl added this to the 2.0 milestone Jan 12, 2023
@phofl phofl merged commit e27bded into pandas-dev:main Jan 12, 2023
@phofl
Copy link
Member

phofl commented Jan 12, 2023

thx @lithomas1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants